﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using FineUICore;
using Kalman;
using Kalman.Extensions;
using QuDao;

namespace AdminUI.Pages.Finance
{
    public partial class CashApplyConfirmModel : BaseModel
    {
        public void OnGet(long id)
        {
            Current = CashApplyBO.Instance.GetItem<CashApply>(id);
            var userList = UserBO.Instance.GetListByRole(OnlineTID, 1);
            ViewBag.UserList = userList;
        }

        public CashApply Current { get; set; }

        public IActionResult OnPostBtnSubmit_Click(long id, string tradeNo, DateTime paymentTime, long operatorID)
        {
            try
            {
                CashApplyBO.Instance.Confirm(id, tradeNo, paymentTime, operatorID);
                var js = ActiveWindow.GetHideExecuteScriptReference("onRefreshClick();");
                FineUICore.PageContext.RegisterStartupScript(js); //保存后触发父页面刷新按钮事件
            //FineUICore.PageContext.RegisterStartupScript(ActiveWindow.GetHideRefreshReference());
            //ActiveWindow.HidePostBack();
            }
            catch (Exception ex)
            {
                var msg = ex.Message;
                if (!(ex is AppException && ex.InnerException == null))
                {
                    msg = ex.ToString();
                }

                Alert.Show(msg, "错误信息", MessageBoxIcon.Error);
            }

            return UIHelper.Result();
        }
    }
}